package com.thl.demo;


import android.Manifest;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.View;

import com.zzh.lib.chooser.FileChooser;
import com.zzh.lib.chooser.FileInfo;

import java.util.List;

import androidx.appcompat.app.AppCompatActivity;


public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        String[] strings = {Manifest.permission.WRITE_EXTERNAL_STORAGE};

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            requestPermissions(strings, 10010);
        }

        findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                FileChooser fileChooser = new FileChooser(MainActivity.this, new FileChooser.FileChoosenListener() {
                    @Override
                    public void onFileChoose(List<FileInfo> filePaths) {
                        for (FileInfo filePath : filePaths) {
                            Log.e(">>>>>>>", filePath.getFilePath());
                        }
                    }
                });
                String path = Environment.getExternalStorageDirectory().getAbsolutePath();
                Log.e("-----", path);
                fileChooser.setShowHideFile(true);
                fileChooser.showFile(true);
                fileChooser.setChooseType(FileInfo.FILE_TYPE_ALL);
                fileChooser.setChooseCount(6);
                fileChooser.showExternalSdCard(false);
                fileChooser.setCurrentPath(path);
                fileChooser.open();
            }
        });

    }


}
